package com.nwpu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nwpu.mapper.UserMapper;
import com.nwpu.service.UserService;
import com.nwpu.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author DPH
* @description 针对表【tbl_user】的数据库操作Service实现
* @createDate 2023-05-21 13:15:59
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean saveUser(User user) {
        user.setUpdateTime(new Date());
        return userMapper.insert(user) > 0;
    }

    @Override
    public User getUserById(String id) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",id);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public boolean updateUser(User user) {
        return userMapper.updateById(user) > 0;
    }

    @Override
    public boolean deleteUserById(String id) {
        return userMapper.deleteById(id) > 0;
    }
}




